#include"head.h"
int analysis_execute(char *comment_line,int fd,process_stat_t *stat,transport_protocol_t *msg){
    
    
    //
    int len =strlen(comment_line);
    comment_line[len-1]='\0';
    //分割
    check_command(comment_line,msg); 

    if(msg->flag_stat!=-1){

        //发送消息
        if(msg->flag_work==1||msg->flag_work==2||msg->flag_work==3||msg->flag_work==4||msg->flag_work==7||msg->flag_work==8){
            msg->command=1;
        }
        transport_protocol_t temp_msg;
        temp_msg=*msg;
        if(msg->command==1){
            int ret=0;
        while(ret<=0){
         send(fd,&temp_msg,sizeof(temp_msg),0);
         int flag=0;
         ret= recv(fd,&flag,4,0);
         if(ret==0){
             close(fd);
             connection(&fd);
         }   

        }}

        transport_protocol_t *son_msg=(transport_protocol_t*)malloc(sizeof(transport_protocol_t));
        *son_msg=*msg;

        switch(msg->flag_work){
        case 1:
            ls(fd);
            break;
        case 2:
            cd(fd,msg->buf,stat,msg);
            break;
        case 3:
            rm(fd);
            break;
        case 4:
            printf("%s\n",msg->curr_path); 
            break;
        case 5:
            pthread_t puts_pid;
            son_msg->command=0;
            pthread_create(&puts_pid,NULL,func,son_msg);
            break;
        case 6:
            pthread_t gets_pid;
           son_msg->command=0;
            pthread_create(&gets_pid,NULL,func,son_msg);
            break;
        case 7:
            cl_mkdir(fd);
            break;
        case 8:
            cli_rmdir(fd);
            break;
            //rmdir函数
            //rmdir(fd);
        case 9:
            help();
            break;
        default:
            break;
        }
    }else{
        printf("格式错误\n");
        msg->flag_stat=1;
    }
    return 1;
}    
